package edu_admin;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;

public class Href_Title_Time {
	String[] href, title, time;
    String usefulcode = null;
	BufferedReader br;

	public Href_Title_Time() {
		String allcode = null;
		try {
			URL url = new URL("http://jw.nju.edu.cn/root/index.html");

			try {
				br = new BufferedReader(new InputStreamReader(url.openStream()));
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			String lines = null;
			try {
				while ((lines = br.readLine()) != null) {
					allcode += lines;

				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		} catch (MalformedURLException e) {
			System.out.print("get codes error");
			e.printStackTrace();
		}

		String[] n1 = allcode.split("<!--##begin news##-->");
		String[] n2 = n1[1].split("<!--##end news##-->");
		usefulcode = n2[0];
		

	}

	public void getparts(String str) {
		String m1 = null;
		String m3 = null;

		String[] n1 = str.split("&nbsp;&nbsp;&nbsp;&nbsp;");
		for (int i = 1; i < n1.length; i += 2) {
			m1 += n1[i];
		}
		String[] n2 = m1.split("<a href=\"..");
		href = new String[n2.length];
		title = new String[n2.length];
		for (int i = 1; i < n2.length; i++) {
			String[] n21 = n2[i].split("\" target=\"content\" title=\"");
			href[i - 1] = n21[0];
			String[] n22 = n21[1].split("\">");
			title[i - 1] = n22[0];
            
		}
      
		// to get href and title;
		time = new String[n2.length];
		for (int i = 2; i < n1.length; i += 2) {
			String[] n3 = n1[i].split("</td><td><font size=2>");
			String[] n31 = n3[1].split("</font>");
			time[(i - 2) / 2] = n31[0];
		}
		

	} // to get time;
        
	


}
